//
//  BaseCollectionReusableView.m
//  OrderSys
//
//  Created by 李李善 on 2017/8/23.
//  Copyright © 2017年 com.hx. All rights reserved.
//

#import "BaseCollectionReusableView.h"
#import "UIView+Base.h"
@interface BaseCollectionReusableView()
@end

@implementation BaseCollectionReusableView

- (void)dealloc
{
    //    KDealloc(self.delegate);
    NSLog(@"%@ 这个类被强暴了",NSStringFromClass([self class]));
}


+ (BaseCollectionReusableView *)onCollectionView:(UICollectionView *)collectionView forViewController:(UIViewController *)ViewController reuseIdentifier:(NSString *)reuseIdentifier forforKind:(NSString *)kind forIndexPath:(NSIndexPath *)indexPath
{
    BaseCollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
    if (NO == headerView.isAsInt) {
        headerView.opaque = YES;
        [headerView onAsInitAddView:headerView forViewController:ViewController AtIndexPath:indexPath];
    }
    return headerView;
    
}
-(void)onMainSetSubViewFrame:(void (^)(UIView *, CGPoint, CGSize, CGPoint))layoutBlock;
{
    if (layoutBlock !=self.layoutBlock) {
        self.layoutBlock = layoutBlock;
    }
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGRect frame = self.frame;
    if (self.layoutBlock) {
        self.layoutBlock(self,frame.origin,frame.size,self.center);
    }
    
}

-(MCLabel *)detailLabel
{
    if (!_detailLabel) {
        MCLabel *textL = ({
            MCLabel*l=[MCLabel new];
            l.numberOfLines = 0;
            [self addV:l];
            l;
        });
        _detailLabel = textL;
    }
    return _detailLabel;
}

-(UILabel *)textLabel
{
    if (!_textLabel) {
        UILabel *textL = ({
            UILabel*l=[UILabel new];
            l.numberOfLines = 0;
            [self addV:l];
            l;
        });
        _textLabel = textL;
    }
    return _textLabel;
}

-(UIImageView *)imageView
{
    if (!_imageView) {
        UIImageView *imagev = ({
            UIImageView*l=[ UIImageView new];
            [self addV:l];
            l;
        });
        _imageView = imagev;
    }
    return _imageView;
    
}
-(HLTextField *)textField
{
    if (!_textField) {
        
        HLTextField*textF = ({
            HLTextField*l=[ HLTextField new];
            [self addV:l];
            l;
        });
        _textField = textF;
        
        
    }
    return _textField;
}

-(HLTextView *)textView
{
    if (!_textView) {
        HLTextView*textV = ({
            HLTextView*l=[ HLTextView new];
            [self addV:l];
            l;
        });
        _textView = textV;
        
    }
    return _textView;
}

-(UIButton *)button
{
    if (!_button) {
        UIButton *button = ({
            UIButton *l= [UIButton buttonWithType:UIButtonTypeCustom];
            [self addV:l];
            l;
        });
        _button = button;
    }
    return _button;
}

@end


@implementation BaseCollectionReusableView(createReusableView)

- (void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController AtIndexPath:(NSIndexPath *)indexPath
{
    
}
- (void)update:(id)model forCollectionView:(UICollectionView *)CollectionView AtIndexPath:(NSIndexPath *)indexPath
{
    
}
@end
